//
// SoapTrace.Net - A soap message monitoring utility. 
//
// Copyright (C) 2005 Matthew Ward
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)


using NUnit.Framework;
using SoapTrace.Core.Formatters;
using System;
using System.Drawing;

namespace SoapTrace.Tests.TextFormatting
{
	/// <summary>
	/// Tests altering the formatting of a piece of text.
	/// </summary>
	/// <remarks>Tests the following:
	/// <code>
	/// ------------- 
	///    ------
	/// </code>
	/// </remarks>
	[ TestFixture ]
	public class ChangeTextColourMiddleOfSingleItemTestFixture
	{
		FormattedText m_FormattedText;
		string m_Text1 = "Foo";
		string m_Text2 = "Bar";
		string m_Text3 = "Test";
		Color m_DefaultTextColour = Color.Black;
		Color m_SecondTextColour = Color.Red;
		FormattedTextItem m_FirstTextItem;
		FormattedTextItem m_SecondTextItem;
		FormattedTextItem m_ThirdTextItem;
		
		/// <summary>
		/// Initialises each test.
		/// </summary>
		[ SetUp ]
		public void Init( )
		{
			m_FormattedText = new FormattedText( m_DefaultTextColour );
			m_FormattedText.Append( String.Concat( m_Text1, m_Text2, m_Text3 ) );
			m_FormattedText.SetColour( m_SecondTextColour, m_Text1.Length, m_Text2.Length );
			
			m_FirstTextItem = m_FormattedText.Items[ 0 ];
			m_SecondTextItem = m_FormattedText.Items[ 1 ];
			m_ThirdTextItem = m_FormattedText.Items[ 2 ];
		}
		
		/// <summary>
		/// Check the number of text items is correct.
		/// </summary>
		[ Test ]
		public void TextItemCount( )
		{
			Assert.AreEqual( 3, m_FormattedText.Items.Count, 
			                "Expecting 3 text items." );
		}
		
		/// <summary>
		/// Checks the second item's text colour.
		/// </summary>
		[ Test ]
		public void SecondTextItemTextColour( )
		{
			Assert.AreEqual( m_SecondTextColour, m_SecondTextItem.Colour, 
			                "Second text item's colour is wrong." );
		}
		
		/// <summary>
		/// Checks the first item's text colour.
		/// </summary>
		[ Test ]
		public void FirstTextItemTextColour( )
		{
			Assert.AreEqual( m_DefaultTextColour, m_FirstTextItem.Colour, 
			                "First text item's colour is wrong." );
		}
		
		/// <summary>
		/// Checks the third item's text colour.
		/// </summary>
		[ Test ]
		public void ThirdTextItemTextColour( )
		{
			Assert.AreEqual( m_DefaultTextColour, m_ThirdTextItem.Colour, 
			                "Third text item's colour is wrong." );
		}		
		
		/// <summary>
		/// Checks the second item's text.
		/// </summary>
		[ Test ]
		public void SecondTextItemText( )
		{
			Assert.AreEqual( m_Text2, m_SecondTextItem.Text, 
			                "Second item's text is wrong." );
		}
		
		/// <summary>
		/// Checks the first item's text.
		/// </summary>
		[ Test ]
		public void FirstTextItemText( )
		{
			Assert.AreEqual( m_Text1, m_FirstTextItem.Text, 
			                "First item's text is wrong." );
		}		
		
		/// <summary>
		/// Checks the third item's text.
		/// </summary>
		[ Test ]
		public void ThirdTextItemText( )
		{
			Assert.AreEqual( m_Text3, m_ThirdTextItem.Text, 
			                "Third item's text is wrong." );
		}			
	}
}
